<template>
     <div class="component-tab-box" :class="{ 'pad-lg': padlg }">
        <!-- <div class="item" @click="onClickTab(item)" :class="{'w-6': type === 'w6', 'w-4': type === 'w4'}" v-for="(item, index) in tabs" :key="index">
            <div class="icon-box text-center">
                <-- &#xe602; ->
                <div class="icon" v-if="item.icon" v-html="item.icon"></div>
                <img class="icon-png" :src="item.png" alt="" v-if="item.png">
            </div>
            <div class="text color-font-2 text-small">{{item.text}}</div>
        </div> -->
        <div class="ShopTabbox">
            <div class="ShopTabbox_item text-center" :class="[item.wd]"  @click="onClickTab(item)" v-for="(item, index) in tabs" :key="index">
                <img :src="item.png" class="ShopTabbox_item_img" alt="" />
                <div class="ShopTabbox_item_title">{{item.text}}</div>
            </div>
        </div>
    </div>
</template>
<script>
import {
    api,
} from '@/lib/api';

export default {
    name: 'TabBox',
    props: {
        tabs: {
            type: Array,
            required: true,
        },
        padLg: {
            type: Boolean,
            default: true,
        },
        type: {
            type: String,
            default: 'w5',
        },
        callBack: {
            type: Function,
        },
        routeType: {
            type: String,
            default: 'navigate',
        },
    },
    methods: {
        onClickTab(item) {
            if (item.callBack) {
                this.$emit('click-call-back', item.callBack);
            }
            if (item.to) {
                api.push(Object.assign({}, item.to));
            }
            if(item.openSlide){
                this.$emit('openSlideMenu', item.openSlide);
            }
        },
    },
};
</script>

<style lang="less">
@import "../../lib/style/mixins.less";

.component-tab-box {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    align-items: center;
    box-sizing: border-box;
    width: 344px;
    // height: 120px;
    padding: 5px 0;
    margin-left: 15px;
    text-align: center;
    border-radius: 10px;
    // background-color: rgba(245, 245, 245, 0.67);
    // box-shadow: 0px 1px 1px 0px rgba(0, 0, 0, 0.4);
    // border: 1px solid rgba(245, 245, 245, 0.67);
    &.pad-lg {
        padding: 32rpx 48rpx;
    }
    .item {
        width: 20%;
        padding: 5px 0;
        &.w-6 {
            width: 100% / 6;
        }
        &.w-4 {
            width: 100% / 4;
        }
        .icon {
            display: inline-block;
            font-size: 26px;
        }
        .icon-png {
            width: 28px;
            height: 28px;
        }
    }
}

.ShopTabbox {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    // padding: 5px 14px;
    // margin-top: -10px;
    .ShopTabbox_item{
        width: 20%;
        margin-bottom: 10rpx;
    }
    .ShopTabbox_item_img{
        width: 100rpx;
        height: 100rpx;
        border-radius: 50%;
        margin: 15rpx auto;
    }
    .ShopTabbox_item_title{
        width: 100%;
        text-align: center;
        font-size: 24rpx;
    }
    .bg-pink {
        background-color: #FFEDED;
        .icon {
            color: #fababd;
        }
    }
    .bg-blue {
        background-color: #E7F3FF;
        .icon {
            color: #9ec6fa;
        }
    }
}
</style>
